﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;

namespace Freshome.p.fox
{
    public static class ActionLinkHelper
    {
        public static MvcHtmlString AjaxImageLink(this AjaxHelper helper, string imageUrl, string altext, string actionName,
            string controller, object routeValues, AjaxOptions options, string imgClass, object htmlAttributes)
        {
            var tag = new TagBuilder("img");
            tag.MergeAttribute("src", imageUrl);
            tag.MergeAttribute("alt", altext + " image");
            tag.MergeAttribute("title", altext);
            tag.AddCssClass(imgClass);
            var lnk = helper.ActionLink("[replaceme]", actionName, controller, routeValues, options, htmlAttributes);
            return new MvcHtmlString(lnk.ToHtmlString().Replace("[replaceme]", tag.ToString(TagRenderMode.SelfClosing)));
        }
        public static MvcHtmlString ActionImageLink(this HtmlHelper helper, string imageUrl, string altext, string actionName,
            string controller, object routeValues, string imgClass, object htmlAttributes)
        {
            var tag = new TagBuilder("img");
            tag.MergeAttribute("src", imageUrl);
            tag.MergeAttribute("alt", altext + " image");
            tag.MergeAttribute("title", altext);
            tag.AddCssClass(imgClass);
            var lnk = helper.ActionLink("[replaceme]", actionName, controller, routeValues, htmlAttributes);
            return new MvcHtmlString(lnk.ToHtmlString().Replace("[replaceme]", tag.ToString(TagRenderMode.SelfClosing)));
        }
    }
}